﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace Aletfa.LightManager.Board
{
    internal static class GridExtensions
    {
        public static UnitPieceControl GetPiece(this Grid grid, int column, int row)
        {
            var elements = from UIElement element in grid.Children
                           where Grid.GetRow(element) == row &&
                                 Grid.GetColumn(element) == column
                           select element;
            return elements.OfType<UnitPieceControl>().FirstOrDefault();
        } 
    }
}
